package com.rfid.project.util;

import java.util.*;
import java.io.*;
import org.springframework.util.ResourceUtils;

public class SystemConfig {

	public static Properties properties = new Properties();
	public static boolean loaded = false;
	
	private synchronized static void tryLoadConfigFile(){
		if(loaded==false){
			try{
			//	FileSystemUtils.
				File file = ResourceUtils.getFile("classpath:global.config");
				if(file!=null){
					properties.load(new FileInputStream(file));
					loaded= true;
				}
			}catch(Exception e){
				e.printStackTrace();
			}
		}
	}
	
	public static int getIntValue(String key){
		tryLoadConfigFile();
		Object value = properties.get(key);
		if(value!=null){
			return Integer.parseInt(value.toString());
		}else{
			return -1;
		}
	}

	public static String getValue(String key){
		tryLoadConfigFile();
		Object value = properties.get(key);
		if(value!=null){
			return value.toString();
		}else{
			return null;
		}
	}

	
	public static void main(String[] args) {
		System.out.println(getValue("Position_Employee_Id"));
	}
	
}
